const { reject } = require('lodash');
const MyPromise = require('./4');

function p1 () {
    return new MyPromise(function (resolve, reject) {
        setTimeout(function () {
            resolve('p1')
        }, 2000)
    })
}
function p2 () {
    return new MyPromise(function (resolve, reject) {
        reject('p2')
        // resolve('成功');
    })
}
// p1 ().then(value => console.log(value))
//     // .catch(reason => console.log(reason))
//     .finally(() => {
//         console.log('finally')
//     })

// p2()
//     .then(value => console.log(value))
//     .catch(reason => console.log(reason))

let p3 = new MyPromise((resolve, reject) => {
    resolve();
});
let p4 = p3.then(() => {
    return p3
})
p4.then( () => {
    console.log(1)
},
(reason) => {
    console.log(reason)
})